< previous page page_621 next page >

Page 621
0621-01.jpg
Figure 15.13.
The results of the 
DELETE statement with a complex WHERE clause.
You can also use the DELETE statement to delete records in more than one table at a time. These multitable deletes can only be performed on tables that have a one-to-one relationship. The example in Listing 15.13 shows modifications to SQLVB08.SQV to illustrate the use of the JOIN clauses to create a multitable DELETE statement. Use SQL-VB5 to edit your copy of SQLVB08.SQV to match the one in Listing 15.13. Save and execute the script and refer to Figure 15.14 for comparison.
Type.gifListing 15.13. Using JOIN to perform a multitable DELETE.
//
// sqlvb08.sqv - Testing DELETE statements
//
// create a new database
dbMake sqlvb08.mdb;
// create a table to work with
CREATE TABLE Table1
   (RecID TEXT(10),
    LastName TEXT(30),
    FirstName TEXT(30),
    RecType TEXT(5),
    Amount CURRENCY,
    LastPaid DATE
   );
// add some records to work with
INSERT INTO Table1 VALUES
   ('R01',
continues

 
< previous page page_621 next page >

If you like this book, buy it!